<!DOCTYPE html>
<html>
<!-- Copyright 2010 andry.virvich@gmail.com. All Rights Reserved. -->
<head>
  <title>JIRA Firefox Extension Options</title>
  <style type="text/css">

  </style>
	<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
	<script type="text/javascript" src="js/local_storage.js"></script>
	<script type="text/javascript">
var wnd = null;
var jira_loader = null;
	function JiraInit(tool, _wnd){
		jira_loader = tool;
		wnd =_wnd;
		wnd.resizeTo(750,270);
	}
	
  function restoreOptions(){
	$("#username").attr("value",  JiraLocalStorage.getItem('username'));
	$("#password").attr("value",  JiraLocalStorage.getItem('password'));
	$("#url").attr("value",  (JiraLocalStorage.getItem('url')?JiraLocalStorage.getItem('url'):"http://jira.atlassian.com/"));
	var vals = [1, 3, 5, 10, 30, 60];
	var curval = parseInt(JiraLocalStorage.getItem('updateinterval'))/(1000*60);
	$.map(vals,function(val){
		$("#updateinterval").append($("<OPTION "+((val == curval)?"SELECTED":'')+" />").attr("value", val).text(val));
	});
	$("#error").text(JiraLocalStorage.getItem('error'));
  }
  function saveOptions(){

	JiraLocalStorage.setItem('username', $("#username").attr("value"));
	JiraLocalStorage.setItem('password', $("#password").attr("value"));
	JiraLocalStorage.setItem('url', $("#url").attr("value").replace(/\/$/,""));	
	JiraLocalStorage.setItem('updateinterval', parseInt($("#updateinterval").attr("value"))*60000);
		jira_loader.url = JiraLocalStorage.getItem("url");
		jira_loader.login(JiraLocalStorage.getItem("username"), JiraLocalStorage.getItem("password"), function(){
			jira_loader.update();
		});
	alert("Settings was saved");
	wnd.close();
  }
  </script>
</head>

<body onload="restoreOptions()">
	<table style="width:100%;height:100%;">
		<tr>
			<td valign="center">
				<center>
				<font size="5" face="calibri, tahoma" color="#2e6eaf">JIRA Firefox Extension Options</font>
				<table style="border:8px solid #87b6d9; border-radius:10px; background-color:#e2e4ff;padding:15px;font-family: Calibri, tahoma">
				<tr>
					<td align="right">Username: </td>
					<td><input id="username" type="text" /></td>
				</tr>
				<tr>
					<td align="right">Password:</td>
					<td><input type="password" id="password" type="text" /></td>
				</tr>
				<tr>
					<td align="right">Jira URL:</td>
					<td><input id="url" type="text" /></td>
				</tr>
				<tr>
					<td align="right">Update Interval:</td>
					<td><select id="updateinterval" ></select>, min</td>
				<tr>
				<tr>
					<td colspan="2" align="right"><hr/>
						<input type="button" onclick="wnd.close()" value="Cancel" />
						<input type="button" onclick="saveOptions();" value="Save" />
					</td>
				</tr>
				</table>
				<font size="4" color="#AA0000" id="error"/>
				</center>
			</td>
		</tr>
	</table>
</body>
</html>
